package mis.ds.ps.model.obj;

import java.io.Serializable;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import mis.ds.ps.model.iface.ITemposEvitar;

import org.hibernate.proxy.HibernateProxy;

import com.felees.hbnpojogen.persistence.IPojoGenEntity;


/** 
 * Object mapping for hibernate-handled table: tempos_evitar.
 * @author autogenerated
 */

@Entity
@Table(name = "tempos_evitar", catalog = "initial_timetable")
public class TemposEvitar implements Cloneable, Serializable, IPojoGenEntity, ITemposEvitar {

	/** Serial Version UID. */
	private static final long serialVersionUID = -558994939L;

	/** Use a WeakHashMap so entries will be garbage collected once all entities 
		referring to a saved hash are garbage collected themselves. */
	private static final Map<Serializable, Long> SAVED_HASHES =
		Collections.synchronizedMap(new WeakHashMap<Serializable, Long>());
	
	/** hashCode temporary storage. */
	private volatile Long hashCode;
	

	/** Field mapping. */
	private Integer dia;
	/** Field mapping. */
	private Long docenteId;
	/** Field mapping. */
	private Double duracao;
	/** Field mapping. */
	private Integer grau;
	/** Field mapping. */
	private Double hora;
	/** Field mapping. */
	private Long id = 0L; // init for hibernate bug workaround
	/** Field mapping. */
	private String obs;
	/** Field mapping. */
	private Long versao;
	/**
	 * Default constructor, mainly for hibernate use.
	 */
	public TemposEvitar() {
		// Default constructor
	} 

	/** Constructor taking a given ID.
	 * @param id to set
	 */
	public TemposEvitar(Long id) {
		this.id = id;
	}
	
 


 
	/** Return the type of this class. Useful for when dealing with proxies.
	* @return Defining class.
	*/
	@Transient
	public Class<?> getClassType() {
		return TemposEvitar.class;
	}
 

    /**
     * Return the value associated with the column: dia.
	 * @return A Integer object (this.dia)
	 */
	public Integer getDia() {
		return this.dia;
		
	}
	

  
    /**  
     * Set the value related to the column: dia.
	 * @param dia the dia value you wish to set
	 */
	public void setDia(final Integer dia) {
		this.dia = dia;
	}

    /**
     * Return the value associated with the column: docenteId.
	 * @return A Long object (this.docenteId)
	 */
	@Column( name = "docente_id"  )
	public Long getDocenteId() {
		return this.docenteId;
		
	}
	

  
    /**  
     * Set the value related to the column: docenteId.
	 * @param docenteId the docenteId value you wish to set
	 */
	public void setDocenteId(final Long docenteId) {
		this.docenteId = docenteId;
	}

    /**
     * Return the value associated with the column: duracao.
	 * @return A Double object (this.duracao)
	 */
	public Double getDuracao() {
		return this.duracao;
		
	}
	

  
    /**  
     * Set the value related to the column: duracao.
	 * @param duracao the duracao value you wish to set
	 */
	public void setDuracao(final Double duracao) {
		this.duracao = duracao;
	}

    /**
     * Return the value associated with the column: grau.
	 * @return A Integer object (this.grau)
	 */
	public Integer getGrau() {
		return this.grau;
		
	}
	

  
    /**  
     * Set the value related to the column: grau.
	 * @param grau the grau value you wish to set
	 */
	public void setGrau(final Integer grau) {
		this.grau = grau;
	}

    /**
     * Return the value associated with the column: hora.
	 * @return A Double object (this.hora)
	 */
	public Double getHora() {
		return this.hora;
		
	}
	

  
    /**  
     * Set the value related to the column: hora.
	 * @param hora the hora value you wish to set
	 */
	public void setHora(final Double hora) {
		this.hora = hora;
	}

    /**
     * Return the value associated with the column: id.
	 * @return A Long object (this.id)
	 */
    @Id 
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column( name = "id", nullable = false  )
	public Long getId() {
		return this.id;
		
	}
	

  
    /**  
     * Set the value related to the column: id.
	 * @param id the id value you wish to set
	 */
	public void setId(final Long id) {
		// If we've just been persisted and hashCode has been
		// returned then make sure other entities with this
		// ID return the already returned hash code
		if ( (this.id == null || this.id == 0L) &&
				(id != null) &&
				(this.hashCode != null) ) {
			SAVED_HASHES.put( id, this.hashCode );
		}
		this.id = id;
	}

    /**
     * Return the value associated with the column: obs.
	 * @return A String object (this.obs)
	 */
	@Column( length = 256  )
	public String getObs() {
		return this.obs;
		
	}
	

  
    /**  
     * Set the value related to the column: obs.
	 * @param obs the obs value you wish to set
	 */
	public void setObs(final String obs) {
		this.obs = obs;
	}

    /**
     * Return the value associated with the column: versao.
	 * @return A Long object (this.versao)
	 */
	public Long getVersao() {
		return this.versao;
		
	}
	

  
    /**  
     * Set the value related to the column: versao.
	 * @param versao the versao value you wish to set
	 */
	public void setVersao(final Long versao) {
		this.versao = versao;
	}


   /**
    * Deep copy.
	* @return cloned object
	* @throws CloneNotSupportedException on error
    */
    @Override
    public TemposEvitar clone() throws CloneNotSupportedException {
		
        final TemposEvitar copy = (TemposEvitar)super.clone();

		copy.setDia(this.getDia());
		copy.setDocenteId(this.getDocenteId());
		copy.setDuracao(this.getDuracao());
		copy.setGrau(this.getGrau());
		copy.setHora(this.getHora());
		copy.setId(this.getId());
		copy.setObs(this.getObs());
		copy.setVersao(this.getVersao());
		return copy;
	}
	


	/** Provides toString implementation.
	 * @see java.lang.Object#toString()
	 * @return String representation of this class.
	 */
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		
		sb.append("dia: " + this.getDia() + ", ");
		sb.append("docenteId: " + this.getDocenteId() + ", ");
		sb.append("duracao: " + this.getDuracao() + ", ");
		sb.append("grau: " + this.getGrau() + ", ");
		sb.append("hora: " + this.getHora() + ", ");
		sb.append("id: " + this.getId() + ", ");
		sb.append("obs: " + this.getObs() + ", ");
		sb.append("versao: " + this.getVersao());
		return sb.toString();		
	}


	/** Equals implementation. 
	 * @see java.lang.Object#equals(java.lang.Object)
	 * @param aThat Object to compare with
	 * @return true/false
	 */
	@Override
	public boolean equals(final Object aThat) {
		Object proxyThat = aThat;
		
		if ( this == aThat ) {
			 return true;
		}

		
		if (aThat instanceof HibernateProxy) {
 			// narrow down the proxy to the class we are dealing with.
 			try {
				proxyThat = ((HibernateProxy) aThat).getHibernateLazyInitializer().getImplementation(); 
			} catch (org.hibernate.ObjectNotFoundException e) {
				return false;
		   	}
		}
		if (aThat == null)  {
			 return false;
		}
		
		final TemposEvitar that; 
		try {
			that = (TemposEvitar) proxyThat;
			if ( !(that.getClassType().equals(this.getClassType()))){
				return false;
			}
		} catch (org.hibernate.ObjectNotFoundException e) {
				return false;
		} catch (ClassCastException e) {
				return false;
		}
		
		
		boolean result = true;
		result = result && (((this.getId() == null) && ( that.getId() == null)) || (this.getId() != null  && this.getId().equals(that.getId())));
		result = result && (((getDia() == null) && (that.getDia() == null)) || (getDia() != null && getDia().equals(that.getDia())));
		result = result && (((getDocenteId() == null) && (that.getDocenteId() == null)) || (getDocenteId() != null && getDocenteId().equals(that.getDocenteId())));
		result = result && (((getDuracao() == null) && (that.getDuracao() == null)) || (getDuracao() != null && getDuracao().equals(that.getDuracao())));
		result = result && (((getGrau() == null) && (that.getGrau() == null)) || (getGrau() != null && getGrau().equals(that.getGrau())));
		result = result && (((getHora() == null) && (that.getHora() == null)) || (getHora() != null && getHora().equals(that.getHora())));
		result = result && (((getObs() == null) && (that.getObs() == null)) || (getObs() != null && getObs().equals(that.getObs())));
		result = result && (((getVersao() == null) && (that.getVersao() == null)) || (getVersao() != null && getVersao().equals(that.getVersao())));
		return result;
	}
	
	/** Calculate the hashcode.
	 * @see java.lang.Object#hashCode()
	 * @return a calculated number
	 */
	@Override
	public int hashCode() {
		if ( this.hashCode == null ) {
			synchronized ( this ) {
				if ( this.hashCode == null ) {
					Long newHashCode = null;

					if ( getId() != null ) {
						newHashCode = SAVED_HASHES.get( getId() );
					}
					
					if ( newHashCode == null ) {
						if ( getId() != null && getId() != 0L) {
							newHashCode = getId();
						} else {
							newHashCode = (long) super.hashCode();

						}
					}
					
					this.hashCode = newHashCode;
				}
			}
		}
		return (int) (this.hashCode & 0xffffff);
	}
	

	
}
